home *** CD-ROM | disk | FTP | other *** search
/ Geek Games #12 / GEGA012.iso / Jogos de Azar / 1721-apuesten.swf / scripts / C_GamesOpenMenuCLASS.as < prev    next >
Text File  |  2006-01-17  |  5KB  |  171 lines

  1. _global.C_GamesOpenMenuCLASS = function()
  2. {
  3.    this.init();
  4. };
  5. C_GamesOpenMenuCLASS.prototype = new MovieClip();
  6. C_GamesOpenMenuCLASS.prototype.init = function()
  7. {
  8.    var o = this.attachMovie("GameMenu:holder","holder_mc",1);
  9.    o._x = -39;
  10.    o._y = 10;
  11.    o._visible = false;
  12.    var tf1 = this.holder_mc.text_mc;
  13.    var tf2 = this.holder_mc.title_mc;
  14.    o = this.textFormats = {};
  15.    o.game = tf1.text_txt.getTextFormat();
  16.    o.game_over = tf1.text_txt.getTextFormat();
  17.    o.game_over.underline = true;
  18.    o.title = tf2.text_txt.getTextFormat();
  19.    tf1.removeMovieClip();
  20.    tf2.removeMovieClip();
  21.    this.loadMenu();
  22.    this.openGames_btn.root = this;
  23.    this.openGames_btn.onRelease = function()
  24.    {
  25.       this.root.open();
  26.    };
  27. };
  28. C_GamesOpenMenuCLASS.prototype.loadMenu = function()
  29. {
  30.    var x = new XML();
  31.    x.root = this;
  32.    x.ignoreWhite = true;
  33.    x.onLoad = function(s)
  34.    {
  35.       if(!s)
  36.       {
  37.          trace("╨╝╨╡╨╜╤Ä ╨╜╨╡ ╨╖╨░╨│╤Ç╤â╨╖╨╕╨╗╨╛╤ü╤î!");
  38.          return undefined;
  39.       }
  40.       this.root.createMenu(this);
  41.    };
  42.    x.load(this.configPath);
  43. };
  44. C_GamesOpenMenuCLASS.prototype.createMenu = function(x)
  45. {
  46.    this.inited = true;
  47.    var a = x.firstChild.childNodes;
  48.    var menu_items = [];
  49.    var o;
  50.    var item;
  51.    var h = this.holder_mc;
  52.    var height;
  53.    h.space_mc._visible = false;
  54.    h.title_mc._visible = false;
  55.    h.text_mc._visible = false;
  56.    var i = 0;
  57.    while(i < a.length)
  58.    {
  59.       o = a[i].attributes;
  60.       if(o.type == "spacer")
  61.       {
  62.          item = h.attachMovie("GameMenu:spacer","spacer_" + i,i);
  63.       }
  64.       else if(o.type == "title")
  65.       {
  66.          item = h.attachMovie("GameMenu:titleText","title_" + i,i);
  67.          item.text_txt.text = o.text;
  68.       }
  69.       else
  70.       {
  71.          item = h.attachMovie("GameMenu:gameText","text_" + i,i);
  72.          item.text_txt.text = o.text;
  73.          if(o.url != "" && o.url != undefined)
  74.          {
  75.             item.url = o.url;
  76.             item.target = o.target;
  77.             item.onRelease = function()
  78.             {
  79.                getURL(this.url,this.target);
  80.                this.clear();
  81.                this._parent._parent.close();
  82.             };
  83.             item.onRollOver = function()
  84.             {
  85.                var tf = new TextFormat();
  86.                tf.underline = true;
  87.                this.text_txt.setTextFormat(tf);
  88.                this.box_mc.gotoAndStop(2);
  89.             };
  90.             item.onRollOut = function()
  91.             {
  92.                this.box_mc.gotoAndStop(1);
  93.                this.clear();
  94.             };
  95.             item.clear = function()
  96.             {
  97.                var tf = new TextFormat();
  98.                tf.underline = false;
  99.                this.text_txt.setTextFormat(tf);
  100.             };
  101.          }
  102.          else
  103.          {
  104.             var tf = new TextFormat();
  105.             tf.color = 10066329;
  106.             item.text_txt.setTextFormat(tf);
  107.          }
  108.       }
  109.       menu_items.push(item);
  110.       height += item._height;
  111.       i++;
  112.    }
  113.    a = menu_items;
  114.    height -= h.space_mc._y;
  115.    var nextY = a[0]._y -= height;
  116.    nextY += a[0]._height;
  117.    var d_y = h.top_mc._y;
  118.    h.top_mc._y = a[0]._y - h.top_mc._height - 14;
  119.    d_y -= h.top_mc._y;
  120.    h.middle_mc._y -= d_y;
  121.    h.middle_mc._height += d_y;
  122.    var i = 1;
  123.    while(i < a.length)
  124.    {
  125.       a[i]._y = nextY;
  126.       nextY += a[i]._height;
  127.       i++;
  128.    }
  129.    this.top_mc.onRelease = this.middle_mc.onRelease = this.bottom_mc.onRelease = function()
  130.    {
  131.    };
  132.    this.top_mc.useHandCursor = this.middle_mc.useHandCursor = this.bottom_mc.useHandCursor = false;
  133. };
  134. C_GamesOpenMenuCLASS.prototype.open = function()
  135. {
  136.    if(!this.inited)
  137.    {
  138.       return undefined;
  139.    }
  140.    var o = this.holder_mc;
  141.    o._visible = true;
  142.    if(_root._xscale != 100)
  143.    {
  144.       var s_index = 100 / _root._xscale;
  145.       o._xscale = 100 * s_index;
  146.       o._yscale = 100 * s_index;
  147.    }
  148.    o = this.listener = {};
  149.    o.root = this;
  150.    o.onMouseDown = function()
  151.    {
  152.       if(!this.root.hitTest(_root._xmouse,_root._ymouse,false))
  153.       {
  154.          this.root.close();
  155.       }
  156.    };
  157.    o.onKeyDown = function()
  158.    {
  159.       this.root.close();
  160.    };
  161.    Mouse.addListener(o);
  162.    Key.addListener(o);
  163. };
  164. C_GamesOpenMenuCLASS.prototype.close = function()
  165. {
  166.    this.removeListener(this.listener);
  167.    this.holder_mc._visible = false;
  168. };
  169. Object.registerClass("C_GamesOpenMenuCLASS",C_GamesOpenMenuCLASS);
  170. delete _global.C_GamesOpenMenuCLASS;
  171.